﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PRO.CashCoupon;
using PRO.Entity;
using PRO.Common;

namespace web.api.cashcoupon
{
    /// <summary>
    /// chack 的摘要说明
    /// </summary>
    public class chack : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (!CVGRequest.GetFormString("_c.h.p").IsNullOrWhiteSpace())
            {
                if (CVGRequest.GetFormString("_c.h.p").IsNumber())
                {
                    if (CVGRequest.GetFormString("_c.h.p").Length != 12)
                        context.Response.Write("-1");
                    else
                    {
                        CashCouponInfo info = CashCouponLib.GetCashCoupon(CVGRequest.GetFormString("_c.h.p"));
                        if (info != null && info.ID > 0)
                        {
                            context.Response.Write("{\"P\":" + info.CashPrice + "}");
                        }
                        else
                            context.Response.Write("0");
                    }

                }
                else
                    context.Response.Write("-1");
            }
            else
                context.Response.Write("-1");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}